package com.szt.sy.util.spring;

import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

/***
 * 环境工具类
 * 
 * @author wwy
 *
 */
@Component
public class EnvironmentUtils {
	
	@Autowired
	private Environment e;
	
	public String getActiveProfile() {
		return e.getActiveProfiles()[0];
	}
	
	public boolean isTest() {
		if (ArrayUtils.contains(e.getActiveProfiles(), "test")) {
			return true;
		}
		return false;
	}
	
	public boolean isDev() {
		if (ArrayUtils.contains(e.getActiveProfiles(), "dev")) {
			return true;
		}
		return false;
	}
	
	public boolean isProd() {
		if (ArrayUtils.contains(e.getActiveProfiles(), "prod")) {
			return true;
		}
		return false;
	}
}
